#include <stdint.h>

#define SIZEOF_ZIP_HEADER 30
#define SIZEOF_ZIP_END_HEADER 22
#define SIZEOF_ZIP_CENTRAL_HEADER 46

#pragma pack( 2 )

typedef struct {
  uint8_t  signature[4];
  uint16_t version;
  uint16_t flags;
  uint16_t compression;
  uint16_t dos_time;
  uint16_t dos_date;
  uint32_t crc32;
  uint32_t compressed_size;
  uint32_t uncompressed_size;
  uint16_t file_name_length;
  uint16_t extra_field_length;
} ZIP_HEADER;

typedef struct {
  uint8_t  signature[4];
  uint16_t version_made;
  uint16_t version;
  uint16_t flags;
  uint16_t compression;
  uint16_t dos_time;
  uint16_t dos_date;
  uint32_t crc32;
  uint32_t compressed_size;
  uint32_t uncompressed_size;
  uint16_t file_name_length;
  uint16_t extra_field_length;
  uint16_t file_comment_length;
  uint16_t disk_number_start;
  uint16_t internal_file_attributes;
  uint32_t external_file_attributes;
  uint32_t position;
} ZIP_CENTRAL_HEADER;

typedef struct {
  uint8_t  signature[4];
  uint16_t number_of_disks;
  uint16_t disk_number_start;
  uint16_t number_of_disk_entries;
  uint16_t number_of_entries;
  uint32_t central_dir_size;
  uint32_t central_dir_offset;
  uint16_t file_comment_length;
} ZIP_END_HEADER;
